//
//  LGCommunityPublishCell.m
//  XieHeHeartDisease
//
//  Created by 1234 on 2024/1/23.
//

#import "LGCommunityPublishCell.h"

@implementation LGCommunityPublishCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setType:(NSString *)type{
    _type = type;
    if([type isEqualToString:@"add"]){
        self.playButton.hidden = YES;
        self.deleteBtn.hidden = YES;
    }else{
        self.playButton.hidden = [type isEqualToString:@"video"]?NO:YES;
        self.deleteBtn.hidden = NO;
    }
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.contentView addSubview:self.imageView];
    [self.contentView addSubview:self.playButton];
    [self.contentView addSubview:self.deleteBtn];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self.contentView);
    }];
    [self.playButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self.contentView);
    }];
    [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.equalTo(self.contentView);
        make.width.height.equalTo(@(viewPix(20)));
    }];
}
-(UIImageView *)imageView{
    if(!_imageView){
        _imageView = [[UIImageView alloc]init];
        _imageView.userInteractionEnabled = YES;
    }
    return _imageView;
}

-(UIButton *)playButton{
    if(!_playButton){
        _playButton = [UIButton buttonWithImage:@"播放视频" selectImage:@"播放视频"];
    }
    return _playButton;
}

-(UIButton *)deleteBtn{
    if(!_deleteBtn){
        _deleteBtn = [UIButton buttonWithImage:@"删除照片" selectImage:@"删除照片"];
    }
    return _deleteBtn;
}

@end
